package de.projectgoodmorning.alarm.model.generic;

import junit.framework.Assert;
import junit.framework.TestCase;

public class AlarmTest extends TestCase {

	private Alarm alarm;
	private String callbackCheck;
	
	@Override
	protected void setUp() throws Exception {
		super.setUp();
		alarm = new Alarm( 0, null );
	}
	
	public void test_it_should_create_with_null_argument() {
		new Alarm( 0, null );
	}
	
	public void test_it_should_inactive_by_creation() {
		Assert.assertTrue( alarm.state == Alarm.INACTIVE );
	}
	
	public void test_it_should_not_execute_an_null_callback() {
		alarm.execute( null );
	}
	
	public void test_it_should_execute_callback() {
		alarm = new Alarm( 0, new AlarmCallback() {
			@Override
			public void callback( Object obj ) {
				callbackCheck = obj.toString();
			}
		} );
		
		String check = "Hello";
		alarm.execute( check );
		assertTrue( callbackCheck.equals( check ) );
	}
}
